
from fastapi import Depends, Query
from core.dependencies import Paging, QueryParams


class JobParams(QueryParams):
    """
    列表分页
    """

    def __init__(
            self,
            activation_code: str = Query(None, description="激活码"),
            task_type: str = Query(None, description="任务类型"),
            status: str = Query(None, description="状态"),
            params: Paging = Depends()
    ):
        super().__init__(params)
        self.activation_code = activation_code
        self.task_type = task_type
        self.status = status
        self.v_order_field = "create_datetime"
        self.v_order = "desc"
        if activation_code:
            self.page = 1
            self.limit = 999


class ScheduleParams(QueryParams):
    """
    列表分页
    """

    def __init__(
            self,
            activation_code: str = Query(None, description="激活码"),
            params: Paging = Depends()
    ):
        super().__init__(params)
        self.activation_code = activation_code
        self.v_order_field = "create_datetime"
        self.v_order = "desc"
        if activation_code:
            self.page = 1
            self.limit = 999


class JobLogsParams(QueryParams):
    """
    列表分页
    """
    def __init__(
            self,
            task_id: str = Query(..., description="任务ID"),
            params: Paging = Depends()
    ):
        super().__init__(params)
        self.task_id = task_id
        self.v_order_field = "create_datetime"
        self.v_order = "desc"

